# @Time    : 2024/12/31 15:01
# @Author  : Zhang Yihao
import os

file1 = open('photo.jpg', mode='rb+')
file1.seek(0, os.SEEK_SET)
while True:
    b = file1.read(1)
    if not b:
        break
    inverted_b = bytes(~b[0] & 0xFF)
    # file1.seek(10, os.SEEK_SET)
    file1.write(inverted_b)
    file1.close()